<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once ('../db_conn.php');


$sql="SELECT * FROM tb_newstype";
$a8s=$db->query($sql); //执行语句  $rs是一个结果集
$ab8s=$a8s->fetch_all(MYSQLI_BOTH);
$recc=isset($_GET['recc'])?$_GET['recc']:"";
if($recc>0)
{
$sql="SELECT * FROM  tb_news where id=$recc";
$at=$db->query($sql);
$adrow=$at->fetch_array(MYSQLI_BOTH);
}
$rec=isset($_GET['rec'])?$_GET['rec']:"";

if ($rec>0)
{
    $title=$_POST['title'];
    $typeid=$_POST['cat_id'];
    $sj=$_POST['sj'];
    $content=$_POST['content'];
    

   
    $sql="update tb_news set typeid='$typeid',title='$title',pubdate='$sj',content='$content' where id=$rec LIMIT 1";
    $rs=$db->query($sql);
        if ($rs==FALSE)
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改失败！');";
        echo "window.location.href='article.php'";
        echo "</script>";
    }
    else
    {
        echo "<script language='javascript' type='text/javascript'>";
        echo "alert('修改成功！');";
        echo "window.location.href='article.php'";
        echo "</script>";  
    }
    

}
if($recc>0)
{
require ('addarticle_html1.php');
}
 else {
    require ('article.php');
}

